package com.limespot.api.tree;

import javax.swing.tree.DefaultMutableTreeNode;

import com.limespot.api.User;

public class UserTreeNode extends DefaultMutableTreeNode {
		
	private static final long	serialVersionUID	= -5822537726574384637L;

	public UserTreeNode(User user) {
		super(user);
	}

	
	// ----------------------------------------------------------------------
	// Interface
	// ----------------------------------------------------------------------
	
	@Override
	public boolean getAllowsChildren() {
		return true;
	}
	
	@Override
	public boolean isLeaf() {
		return false;
	}
	
	public User getUser() {
		return (User)getUserObject();
	}

	// ----------------------------------------------------------------------
	// Private
	// ----------------------------------------------------------------------
	
	public boolean equals(Object o) {
		if (!(o instanceof UserTreeNode)) return false;
		UserTreeNode that = (UserTreeNode)o;
		return this.user().equals(that.user());
	}
	
	private User user() {
		return (User)getUserObject();
	}
}
